package com.zeta.api.client.demo;

import com.zeta.api.model.DemoDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.zetaframework.base.result.ApiResult;

/**
 * SeataDemo2服务 Feign接口降级处理
 *
 * @author gcc
 */
@Slf4j
@Component
public class IDemoSeata2ApiFallbackFactory implements FallbackFactory<IDemoSeata2Api> {
    @Override
    public IDemoSeata2Api create(Throwable cause) {
        log.error("SeataDemo2服务 feign接口调用失败: {}", cause.getMessage());
        return new IDemoSeata2Api() {
            @Override
            public ApiResult<Boolean> tryException(DemoDTO demoDTO) {
                return ApiResult.fail("请求超时", false);
            }
        };
    }
}
